#include <iostream>  
#include "cTime_t.h"  
#include "cDate_t.h"
#include <time.h>
using namespace std; 


int main() {

	cTime_t time1;
	int hour, minutes, seconds, objNum, format;
	cout << "Created one cTime object from current time.\nPlease enter hour, minutes and seconds for second object" << endl;
	cin >> hour >> minutes >> seconds;
	cTime_t time2(hour, minutes, seconds);
	cDate_t date1;
	int day, month, year;
	cout << "Created one cDate object from current date.\nPlease enter day, month and year for second object" << endl;
	cin >> day >> month >> year;
	cDate_t date2(day, month, year);

	while(1) {
		cout <<
			"\nsetTime(t) | printTime(p) | rcvHour(h) | rcvMinutes(m) | rcvSeconds(s) | addition(+) | assignmentTime(=)"
			<< "| setDate(d) | printDate(D) | rcvDateParams(r) | assignmentDate(a) | setTimeFormat(f) | setDateFormat(F): ";

		char c;
		cin >> c;

		if(c!='t' && c!='p' && c!='h' && c!='m' && c!='s'
			&& c!='+' && c!='=' && c!='q' && c!='d' && c!='r' && c!='D' && c!='a' && c!='f' && c!='F') {
				cout << "No such command. Try again (q to exit)." << endl;
				continue;
		}

		if (c == 'q') {
			break;
		}
		
		switch (c) {
		   case 't' : 
			   cout << "Which object would you like to execute the command on(1 or 2):" ;
			   cin >> objNum;
			   cout << "Please enter hour, minutes and seconds:" << endl;
				   cin >> hour >> minutes >> seconds;
				   if (objNum == 1) {
					   time1.setTime(hour, minutes, seconds);
					   cout << "First object has changes to: ";
					   time1.print();
				   }else {
					   time2.setTime(hour, minutes, seconds);
					   cout << "Second object has changes to: ";
					   time2.print();
				   }
			   break;
		   case 'd' : 
			   cout << "Which object would you like to execute the command on(1 or 2):" ;
			   cin >> objNum;
			   cout << "Please enter day, month and year:" << endl;
			   cin >> day >> month >> year;
			   if (objNum == 1) {
				   date1.setDate(day, month, year);
				   cout << "First object has changes to: ";
				   date1.print();
			   }else {
				   date2.setDate(day, month, year);
				   cout << "Second object has changes to: ";
				   date2.print();
			   }
			   break;
		   case 'p' : 
			   cout << "First object: ";
			   time1.print();
			   cout << "Second object: ";
			   time2.print();
			   break;
		   case 'D' : 
			   cout << "First object: ";
			   date1.print();
			   cout << "Second object: ";
			   date2.print();
			   break;
		   case 'h' :  
			   cout << "Hour of first object: " << time1.getHour() << endl;
			   cout << "Hour of second object: " << time2.getHour() << endl;
			   break;
		   case 'm' :  
			   cout << "Minutes of first object: " << time1.getMinutes() << endl;
			   cout << "Minutes of second object: " << time2.getMinutes() << endl;
			   break;
		   case 's' :  
			   cout << "Seconds of first object: " << time1.getSeconds() << endl;
			   cout << "Seconds of second object: " << time2.getSeconds() << endl;
			   break;
		   case '+' :  
			   cout << "Which object would you like to execute the command on(1 or 2):" ;
			   cin >> objNum;
			   if (objNum == 1) {
				   time1 + time2;
				   cout << "First object has changes to: ";
				   time1.print();
			   }else {
				   time2 + time1;
				   cout << "Second object has changes to: ";
				   time2.print();
			   }
			   break;
		   case 'r' : 
			   cout << "Which object would you like to execute the command on(1 or 2):" ;
			   cin >> objNum;
			   cout << "Day: " << (objNum == 1 ? date1.getDay() : date2.getDay()) << endl;
			   cout << "Month: " << (objNum == 1 ? date1.getMonth() : date2.getMonth()) << endl;
			   cout << "Year: " << (objNum == 1 ? date1.getYear() : date2.getYear()) << endl;
			   cout << "Day of year: " << (objNum == 1 ? date1.getDayOfYear() : date2.getDayOfYear()) << endl;
			   cout << "Name of day: " << (objNum == 1 ? date1.getDayName() : date2.getDayName()) << endl;
			   cout << "Name of month: " << (objNum == 1 ? date1.getMonthName() : date2.getMonthName()) << endl;
			   cout << "Is year leap: " << (objNum == 1 ? date1.isLeap() : date2.isLeap()) << endl;
			   break;
		   case '=' : 
			   cout << "Which object would you like to execute the command on(1 or 2):" ;
			   cin >> objNum;
			   if (objNum == 1) {
				   time1 = time2;
				   cout << "First object has changes to: ";
				   time1.print();
			   }else {
				   time2 = time1;
				   cout << "Second object has changes to: ";
				   time2.print();
			   }
			   break;
		   case 'a' : 
			   cout << "Which object would you like to execute the command on(1 or 2):" ;
			   cin >> objNum;
			   if (objNum == 1) {
				   date1 = date2;
				   cout << "First object has changes to: ";
				   date1.print();
			   }else {
				   date2 = date1;
				   cout << "Second object has changes to: ";
				   date2.print();
			   }
			   break;
		   case 'f' :
			   cout << "Please choose time format (1:24hrs, 2:12hrs)";
			   cin >> format;
			   cTime_t::setFormat(format);
			   break;
		   case 'F' :
			   cout << "Please choose time format (1:dd/mmm/yyyy, 2:dd/mm/yyyy, 3:mm/dd/yyyy)";
			   cin >> format;
			   cDate_t::setFormat(format);
			   break;
		}
	}

	return 0;
}

